package com.github.caijh.mall.task.cloud;

import com.github.caijh.commons.util.DateUtils;
import com.github.caijh.framework.log.util.LogUtils;
import com.github.caijh.mall.system.service.SystemAttachmentService;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class AsyncCloud {

    private static final Logger logger = LogUtils.getLogger(AsyncCloud.class);

    @Autowired
    private SystemAttachmentService systemAttachmentService;

    @Scheduled(fixedDelay = 1000 * 5L) //5秒钟同步一次数据
    public void init() {
        logger.debug("---AsyncCloud task------Sync Data with fixed rate task: Execution Time - {}", DateUtils.nowAsString());
        try {
            systemAttachmentService.async();
        } catch (Exception e) {
            logger.error("AsyncCloud.task msg : {}", e.getMessage(), e);
        }

    }

}
